package mumu.android.app;

import mumu.android.R;
import mumu.android.lib.localstorage.FileSQLiteOpenHelper;
import mumu.android.lib.tool.Tools;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * 
 * bind服务处理。 关闭activity后，服务终止
 * 
 * @author Administrator
 * 
 */
public class filesqlite extends Activity {

	Button bind, unbind, getServiceStatus;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTitle("bind服务");
		setContentView(R.layout.broadcast1);

		Button btn_3 = (Button) findViewById(R.id.btn_3);// reg
		Button btn_4 = (Button) findViewById(R.id.btn_4);// unreg
		Button btn_1 = (Button) findViewById(R.id.btn_1);// unreg
		// 创建启动Service的Intent
		final Intent intent = new Intent(this, zLib_bindservice.class);
		// 为Intent设置Action属性
		btn_3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

			}
		});
		btn_4.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				try {

					FileSQLiteOpenHelper
							.getInstance(filesqlite.this)
							.getDb()
							.execSQL("insert into hosp (hosp_id,alias,photo,city_code) values (?,?,?,?)",
									new Object[] { "1", "212", "2121", "112"});
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		btn_1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Cursor cursor = FileSQLiteOpenHelper.getInstance(filesqlite.this).getDb().rawQuery("select * from hosp ", new String[] {});
				String string = "";
				while (cursor.moveToNext()) {
					string = cursor.getString(1);
				}
				Tools.toast(filesqlite.this, string);
			}
		});
	}

}
